﻿using System.Text.Json;

namespace K9Nano.LayIM.Internal
{
    internal class TextJsonSerializer : IJsonSerializer
    {
        private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions
        {
            IgnoreNullValues = true,
            PropertyNamingPolicy = JsonNamingPolicy.CamelCase
        };

        public string Serialize(object data)
        {
            return JsonSerializer.Serialize(data, JsonSerializerOptions);
        }

        public T Deserialize<T>(string json)
        {
            return JsonSerializer.Deserialize<T>(json, JsonSerializerOptions);
        }
    }
}